1. Field of the Invention
The present invention relates generally to a method and a system for updating software, and more particularly to a method and a system for updating software stored in a flash memory.
2. Description of the Related Art
With the rapid development of portable devices, such as mobile communication terminals and PDAs (Personal Digital Assistants), digital convergence has driven a new trend to combine a variety of functions and shorten the model replacement cycle. Accordingly, it becomes more likely that new portable devices are supplied on the market with undesired functional defects that have not been detected during the development stage. Also, after completion of the development of a portable device, an additional function may need to be released in a patch form.
In such cases, the software of already-sold portable devices must be updated to correct or upgrade the software defects. Qualified service engineers from the device supplier or after-sales service centers may directly visit all the users of the defective portable devices. Alternatively, the users can visit the after-sales service centers to update the software of their portable devices.
To eliminate such trouble, an OTA-SD (Over The Air-Software Download) has been suggested for portable devices capable of mobile communications. The OTA-SD is a download scheme that accesses a predetermined server through the Internet, and selects an update file to be downloaded and downloads the update file onto a portable device. It is also possible to primarily download an update file onto a PC through the Internet and then transfer the same update file from the PC to a portable device using an USB (Universal Serial Bus) cable.
After downloading an update file, usually, the user reboots the portable device being updated. The updating process is implemented by erasing a area storing a software code to be updated in a non-volatile memory where software is generally stored, and storing a downloaded update software code in the area to be updated. Commonly, a flash memory is used as a non-volatile memory that stores software in a portable device. The flash memory stores software, such as boot codes, application programs, font binaries, and content binaries.
However, the process of updating a portable device by downloading update software may be interrupted by an abnormal cause, for example, when the portable device is suddenly turned off by the separation of a battery. To prepare for the sudden interruption of the updating process, journaling can be implemented. When journaling is utilized, a backup area and a journaling area are allocated in a flash memory so that data stored in a area to be updated can be copied into the backup area and log data indicating the results of implementation of each step of the updating process can be stored in the journaling area. The updating process comprises the steps of copying the data stored in a area to be updated into the backup area, erasing the area to be updated, and storing an update software code in the area to be updated. By having a backup copy of the data stored in the area to be updated before erasing it, it is possible to minimize the chance of losing the data without being updated, when an unexpected power loss occurs after erasure of the area to be updated. Also, upon completion of each of the copying, erasing, and storing steps, log data indicating the results of implementation of each step is stored in the journaling area. Accordingly, when rebooting a device after a temporary power loss during the updating process, the user can refer to the stored log data to resume the updating process from a proper point.
Either an NOR-type flash memory or an NAND-type flash memory can be used as a flash memory storing software in a portable device. Unlike the NOR flash memory, the NAND flash memory often loses all the log data stored in the journaling area when implementing an updating process including a journaling step. The NOR flash memory continuously stores new log data generated during the updating process in an erased journaling area. In other words, after storing one log data in the journaling area, the NOR flash memory stores additional log data next to the previous log data in the journaling area, without erasing the previous log data. The operation of storing log data continues until the journaling area is filled with log data.
Unlike the NOR flash memory, the NAND flash memory has a limitation in the NOP (Number of Program). The NAND flash memory always executes the erase operation before attempting to store data. In the NAND flash memory, the erase operation is executed in 16-Kbyte blocks, while the program and read operations are executed in 512-byte pages. The NOP refers to the number of programming and storing operations, which can be executed without erasing data in a once-erased page. The NOP of the main memory area is defined differently according to NAND flash memory device suppliers.
If the programming and storing operations in the NAND flash memory exceeds the defined NOP, it cannot be guaranteed to correct bit errors due to the physical properties of the NAND flash memory. Because the NAND flash memory operates in pages while programming, a high voltage is supplied to a bit to be programmed and to the other bits within the same page. Accordingly, if the NAND flash memory is programmed to store additional data next to the previous data in the same page without erasure, the previous data will likely be overwritten to be replaced by the new additional data. Then, single bit errors will be repeatedly caused, which may lead to an incorrectable double or multiple bit errors in the NAND flash memory. Because of the double or multiple bit error, the NAND flash memory will have incorrect data. Therefore, if a program operation is executed to store data in an erased NAND flash memory area, the NAND flash memory, unlike the NOR flash memory, cannot keep storing log data without erasure until the journaling area is filled.
If journaling is applied to update software of a portable device because of the physical properties of the NAND flash memory, it will be necessary to first erase the journaling area and then execute a program operation whenever storing log data. However, when an unexpected power loss occurs after erasure of the journaling area, there may be a possibility of losing all the log data previously stored in the journaling area. Accordingly, log data stored in the Journaling area is moved into a RAM (Random Access Memory) before erasing the journaling area. However, if a power loss occurs after erasing the journaling area and before storing new log data from the RAM in addition to the previous log data in the journaling area, all the log data will likely be lost. Therefore, the journaling step for preventing data loss that may be caused by an unexpected power loss during an updating process will be useless in the NAND flash memory.
As stated above, the NAND-type flash memory is required to repeat the erase and program operations to store data. Therefore, journaling may be useless when updating software in a portable device that stores software in the NAND flash memory.